﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;

namespace lcmyjobs.Web.Controls
{
    public partial class NewsListLong : System.Web.UI.UserControl
    {
        private int _count = 0;
        private int _typeid = 0;
        private int _cellscount = 0;
        //private string _linkname = "";
        //private string _linkurl = "";
        private string _infourl = "";

        /// <summary>
        /// 超链接名（显示详细信息的页面，用于li内的链接地址）
        /// </summary>
        public string infourl
        {
            get { return _infourl; }
            set { _infourl = value; }
        }

      
        /// <summary>
        /// 一共两列，每列显示的行数
        /// </summary>
        public int cellscount
        {
            get { return _cellscount; }
            set { _cellscount = value; }
        }
        ///// <summary>
        ///// 超链接名（显示更多信息列表的页面，用于底部“更多”的链接地址）
        ///// </summary>
        //public string linkname
        //{
        //    get { return _linkname; }
        //    set { _linkname = value; }
        //}
        ///// <summary>
        ///// 超链接地址
        ///// </summary>
        //public string linkurl
        //{
        //    get { return _linkurl; }
        //    set { _linkurl = value; }
        //}
        /// <summary>
        /// 类型id
        /// </summary>
        public int typeid
        {
            get { return _typeid; }
            set { _typeid = value; }
        }
        /// <summary>
        /// 列表行数
        /// </summary>
        public int count
        {
            get { return _count; }
            set { _count = value; }
        }


        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Bind();
            }
        }

        private void Bind()
        {
            DataSet ds_jyzd = new lcmyjobs.BLL.news().GetListNews(Convert.ToInt32(Application["webid"].ToString()), count, typeid);//就业指导

           
            if (ds_jyzd.Tables[0].Rows.Count > cellscount)
            {
                StringBuilder str1 = new StringBuilder("");
                StringBuilder str2 = new StringBuilder("");

                str1.Append("<ul>");
                for (int i = 0; i < cellscount; i++)
                {
                    string content = this.GetStr(ds_jyzd.Tables[0].Rows[i]["ntitle"].ToString());
                    // chg by liuhui for伪静态化 131007
                    //str1.Append("<li><a href='" + infourl + "?nid=" + ds_jyzd.Tables[0].Rows[i]["nid"] + "&type_id="+typeid+"'>" + content + "</a></li>");
                    str1.Append("<li><a href='" + infourl + "-" + ds_jyzd.Tables[0].Rows[i]["nid"] + "-" + typeid + ".html'>" + content + "</a></li>");
                }
              
                str1.Append("</ul>");

                this.lti_newslist1.Text = str1.ToString();

                str2.Append("<ul>");
                for (int i = cellscount; i < ds_jyzd.Tables[0].Rows.Count; i++)
                {
                    string content = this.GetStr(ds_jyzd.Tables[0].Rows[i]["ntitle"].ToString());
                    // chg by liuhui for伪静态化 131007
                    //str2.Append("<li><a href='" + infourl + "?nid=" + ds_jyzd.Tables[0].Rows[i]["nid"] + "&type_id=" + typeid + "'>" + content + "</a></li>");
                    str2.Append("<li><a href='" + infourl + "-" + ds_jyzd.Tables[0].Rows[i]["nid"] + "-" + typeid + ".html'>" + content + "</a></li>");
                }

                str2.Append("</ul>");

                this.lti_newslist2.Text = str2.ToString();
              
            }
            else
            {
                StringBuilder str = new StringBuilder("");
                str.Append("<ul>");
                for (int i = 0; i < ds_jyzd.Tables[0].Rows.Count; i++)
                {
                    string content = this.GetStr(ds_jyzd.Tables[0].Rows[i]["ntitle"].ToString());

                    // chg by liuhui for伪静态化 131007
                    //str.Append("<li><a href='" + infourl + "?nid=" + ds_jyzd.Tables[0].Rows[i]["nid"] + "&type_id=" + typeid + "'>" + content + "</a></li>");
                    str.Append("<li><a href='" + infourl + "-" + ds_jyzd.Tables[0].Rows[i]["nid"] + "-" + typeid + ".html'>" + content + "</a></li>");
                }

                str.Append("</ul>");
                this.lti_newslist1.Text = str.ToString();
            }

          


           

        }

        private string GetStr(string str)
        {
            string result = str;
            if (str.Length > 21)
            {
                result = str.Substring(0, 21) + "......";
            }
            return result;
        }
    }
}